#include "Raft/raft.hpp"

#define EVERY_SERVER_PORT 3

enum ERR {
    OK = 0,
    ErrNoKey,
    ErrWrongLeader
};

struct GetArgs{
    string key;
    int clientId;
    int requestId;

    friend Serializer& operator >> (Serializer& in, GetArgs& d) {
		in >> d.key >> d.clientId >> d.requestId;
		return in;
	}
	friend Serializer& operator << (Serializer& out, GetArgs d) {
		out << d.key << d.clientId << d.requestId;
		return out;
	}
};

struct GetReply{
    string value;
    ERR err;

    friend Serializer& operator >> (Serializer& in, GetReply& d) {
		in >> d.value >> d.err;
		return in;
	}
	friend Serializer& operator << (Serializer& out, GetReply d) {
		out << d.value << d.err;
		return out;
	}
};

struct PutAppendArgs{
    string key;
    string value;
    string op;              //区分操作类型put、append
    int clientId;
    int requestId;
    friend Serializer& operator >> (Serializer& in, PutAppendArgs& d) {
		in >> d.key >> d.value >> d.op >> d.clientId >> d.requestId;
		return in;
	}
	friend Serializer& operator << (Serializer& out, PutAppendArgs d) {
		out << d.key << d.value << d.op << d.clientId << d.requestId;
		return out;
	}
};

struct PutAppendReply{
    ERR err;
};

